<template>
	<view>
		<view class="lineGray"></view>
		<view class=" line textTab ">
			<view class="bigEmpty"></view>
			<view :class="{textTab1:tabIndexCategory==1}" @click="changeCategory(1)">
				<view class="padding"><text>我收到的</text></view>
				<view v-show="tabIndexCategory==1" class="line-black" style="margin-left: 20px; margin-right: 20px;">
				</view>
			</view>
			<view :class="{textTab1:tabIndexCategory==2}" @click="changeCategory(2)" class="marginLeft">
				<view class="padding"><text>我发出的</text></view>
				<view v-show="tabIndexCategory==2" class="line-black" style="margin-left: 20px; margin-right: 20px;">
				</view>
			</view>
			<view class="bigEmpty"></view>
		</view>
		<view class="lineGray margin-top-0"></view>
		<view  v-show="tabIndexCategory==2">
			
			<view >
				<view v-for="(item,index) in list2">
					<view class="padding">
						<view class="line">
							<image class="image-head-small" :src="item.user.avator"></image>
							<view class="marginLeft bold">{{item.user.name}}</view>
							<view class="marginLeft bigEmpty">{{item.createTime}}</view>
						</view>
						<view class="marginTop">{{item.content}}</view>
						<view class="padding"></view>
						<view class="lineGray marginTop"></view>
					</view>
			
				</view>
			</view>
			
		</view>
		
	</view>
</template>

<script>
	import request from '/common/request.js';
	export default {
		data() {
			return {
				tabIndexCategory: 1,
				loading: false,
				list2:[]
			}
		},
		onShareAppMessage(res) {
			return {
				title: '设辑-产品设计智能生成AI',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/black-logo.png'
			}
		},
		// 自定义页面的分享到朋友圈
		onShareTimeline(res) {
			return {
				title: '设辑-产品设计智能生成AI',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/black-logo.png'
			}
		},
		onLoad() {
			this.requstData();
		},
		methods: {
			changeCategory(num) {
				this.tabIndexCategory = num;
			},

			requstData() {
				const that = this;
				if (that.loading) {
					return
				}
				that.loading = true;
				const url1 = getApp().globalData.apiUrl + "/api/v1/comment/mine";
				request(url1, "GET", {
						page: that.page,
						type: 1
					}, uni.getStorageSync("token"))
					.then(function(res) {
						console.log('返回正确回调', res)
						that.page = that.page + 1;
						that.loading = false;
						that.list2=res.data
					}, function(err) {
						console.log('返回错误回调', err)
						that.loading = false;
					})

			},
		}
	}
</script>

<style>
	@import url("../../common/uni.css");




</style>